﻿using System.Modules.SharePoint.Contracts.Enums;

namespace System.Modules.SharePoint.Contracts.DTO
{
    /// <summary>
    /// SP Query Recurrence Builder
    /// </summary>
    public class SPQueryRecurrenceBuilder : SPQueryCondition
    {
        #region Properties
        /// <summary>
        /// DateRangesOverlap
        /// </summary>
        public SPQueryDateRangesOverlap DateRangesOverlap { get; set; } 
        #endregion

        #region Constructors
        /// <summary>
        /// Default Constructor
        /// </summary>
        public SPQueryRecurrenceBuilder() : this(SPQueryCamlDateValues.Month) { }

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="value"></param>
        public SPQueryRecurrenceBuilder(SPQueryCamlDateValues value)
        {
            DateRangesOverlap.Fields.Add(new SPQueryFieldRef(EventListItem.FieldNames.EventDate.ToString()));
            DateRangesOverlap.Fields.Add(new SPQueryFieldRef(EventListItem.FieldNames.EndDate.ToString()));
            DateRangesOverlap.Fields.Add(new SPQueryFieldRef(EventListItem.FieldNames.RecurrenceID.ToString()));
            DateRangesOverlap.Value = value;
        }
        #endregion

        #region Override
        /// <summary>
        /// Overrides To String
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            return DateRangesOverlap.ToString();
        }
        #endregion
    }
}
